package com.frxuexi.user.viewmodel

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.user.intent.UserIntent
import com.frxuexi.user.repository.UserRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class UserViewModel @Inject constructor(private val userRepository: UserRepository):BaseViewModel<UserIntent> (){
    override fun handleIntent(intent: UserIntent) {
        when(intent){
            is UserIntent.register->{
                roomRequest(userRepository.register(intent.user))
            }
            is UserIntent.login->{
                roomRequest(userRepository.login(intent.uname,intent.pass,intent.role))
            }
        }
    }
}